package com.yxp.manager.exception;


import com.yxp.manager.common.ResponseCode;
import com.yxp.manager.common.ServerResponse;

/**
 * 业务异常类
 * @author yxp
 * @date 2019/5/28 16:58
 */
public class BizException extends RuntimeException {

    private String code;

    private String message;

    private ResponseCode responseCode;

    public BizException(ResponseCode responseCode) {
        super(responseCode.getDesc(ServerResponse.locale));
        this.code = responseCode.getCode();
        this.message = responseCode.getDesc(ServerResponse.locale);
        this.responseCode = responseCode;
    }

    /**
     * 优先使用构造函数 {@link BizException#BizException(ResponseCode)}
     * @author yxp
     * @date 2019/9/6 11:53
     */
    //@Deprecated
    public BizException(String code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public ResponseCode getResponseCode() {
        return this.responseCode;
    }
    
    @Override
    public String toString() {
    	return this.getCode() + "," + this.getMessage();
    }

}
